<template>
  <div class="count">
    <h1>Count</h1>
    <h2>当前的num值是:{{ $store.state.num }}</h2>
    <h2>当前的doubleNum值是:{{ $store.getters.doubleNum }}</h2>
    <div>
      <button @click="$store.commit('increment')">累加num-原始操作</button>
      <button @click="increment">累加num-封装操作</button>
      <button @click="$store.commit('incrementN', { n: 2 })">
        累加N -- num--原始操作
      </button>

      <button @click="incrementN({ n: 2 })">累加N -- num--封装方法操作</button>

      <button @click="$store.dispatch('incrementWait')">
        延迟1s累加-原始操作
      </button>
      <button @click="incrementWait">延迟1s累加</button>
      <button @click="$store.dispatch('incrementNWait', { n: 2 })">
        延迟1s累加n--原始操作
      </button>
      <button @click="incrementNWait({ n: 2 })">延迟1s累加n</button>
    </div>
  </div>
</template>

<script>
import { mapMutations, mapActions } from "vuex";
export default {
  name: "Count",
  mounted() {
    console.log(this);
  },
  methods: {
    ...mapActions(["incrementNWait", "incrementWait"]),
  },
};
</script>

<style scoped>
.count {
  background: pink;
}
</style>
